import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule } from '@nestjs/config';
import { AuthGuard } from './modules/system/auth/auth.guard';
import { ApiBearerAuth } from '@nestjs/swagger';
import { AutoRegisterModule } from './common/utils/auto-register.util';


@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: '127.0.0.1',
      port: 3306,

      username: 'root',
      password: '554300',

      database: 'study_system',
      entities: [__dirname + '/**/*.entity{.ts,.js}'],
      synchronize: true, // 在开发环境中使用，生产环境中建议设置为 false
    }),
    AutoRegisterModule.registerModules({
      path: '../../modules', // 自动注册模块的路径
    }),
    
  ],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'APP_GUARD',
      useClass: AuthGuard, // 全局使用 AuthGuard
    },
  ],
})
export class AppModule {}
